package com.gs.weather.service.impl;


import com.gs.weather.dao.DisasterSubtypeDao;
import com.gs.weather.entity.DisasterSubtype;
import com.gs.weather.service.DisasterSubtypeService;
import com.gs.weather.utils.HttpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/9/21 0021
 */
@Service
public class DisasterSubtypeServiceImpl implements DisasterSubtypeService{

    @Autowired
    DisasterSubtypeDao disasterSubtypeDao;

    @Override
    public Integer addSubtype(DisasterSubtype subtype) {
        return disasterSubtypeDao.addDisasterSubtype(subtype);
    }

    @Override
    public ResponseEntity updateSubtype(DisasterSubtype subtype) {
        disasterSubtypeDao.updateDisasterSubtype(subtype);
        return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
    }

    @Override
    public List<DisasterSubtype> getSubtypeByTypeId(int id) {
        List<DisasterSubtype> subtypes = disasterSubtypeDao.queryDisasterSubtypeByDisasterTypeId(id);
        return subtypes;
    }

    @Override
    public ResponseEntity deleteSubtype(int id) {
        disasterSubtypeDao.deleteDisasterSubtype(id);
        return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
    }
}
